<template>
	<view class="container" :style="{paddingTop: statusBarHeight + 'px'}">
		<view class="user_info">
			<view class="avatar">
				<image :src="userinfo.avatar" mode="widthFix"></image>
			</view>
			<view class="other_info">
				<view class="name">
					<text>{{userinfo.username}}</text>
					<text class="type">{{userinfo.offline_role_text}}</text>
				</view>
				<view class="phone">
					{{userinfo.mobile}}
				</view>
			</view>
		</view>
		<!-- 我的服务 -->
		<view class="card my_service">
			<view class="title">
				我的服务
			</view>
			<view class="service_list">
				<view class="service_item" style="background: #FFF7F2;" @click="toCooperationApply">
					<view class="item_img">
						<image src="/static/icon_cooperation_apply.png" mode="widthFix"></image>
					</view>
					<view class="item_name">
						申请合作
					</view>
				</view>
				<view class="service_item" style="background: #FFF7EA;" @click="toStoreData">
					<view class="item_img">
						<image src="/static/icon_store_data.png" mode="widthFix"></image>
					</view>
					<view class="item_name"> 门店数据 </view>
				</view>
				<view class="service_item" style="background:  #EBF9FF;" @click="toMyShare">
					<view class="item_img">
						<image src="/static/icon_share.png" mode="widthFix"></image>
					</view>
					<view class="item_name"> 我的分享 </view>
				</view>
				<!-- <view class="service_item service_item_last" style="background: #EAF5FF;" @click="toShare">
					<view class="item_img">
						<image src="/static/icon_invite.png" mode="widthFix"></image>
					</view>
					<view class="item_name"> 邀请好友 </view>
				</view> -->
				<button open-type="share"  class="service_item service_item_last service_item_share" style="background: #EAF5FF;" >
					<view class="item_img">
						<image src="/static/icon_invite.png" mode="widthFix"></image>
					</view>
					<view class="item_name"> 邀请好友 </view>
				</button>
			</view>
		</view>
		
		<view class="other_service">
			<view class="other_service_list">
				<view class="other_service_item commission" @click="myServices">
					<view class="item_name">
						我的服务
					</view>
					<view class="item_img">
						<image src="/static/icon_my_service.png" mode="widthFix"></image>
					</view>
				</view>
				<view class="other_service_item orders" @click="myOrders">
					<view class="item_name">
						我的订单
					</view>
					<view class="item_img">
						<image src="/static/icon_my_orders.png" mode="widthFix"></image>
					</view>
				</view>
				<view class="other_service_item hxewm"  v-if="userinfo.offline_role == '1'" @click="myVerification">
					<view class="item_name">
						我的核销
					</view>
					<view class="item_img">
						<image src="/static/icon_verification.png" mode="widthFix"></image>
					</view>
				</view>
				<view class="other_service_item hxewm"  v-if="userinfo.offline_role != '1'">
					<view class="item_name">
						核销二维码
					</view>
					<view class="item_img">
						<image src="/static/icon_hx_ewm.png" mode="widthFix"></image>
					</view>
				</view>
			</view>
		</view>
		
		<view class="cell"  @click="myCommission">
			<view class="left_icon">
				<image src="/static/icon_commission.png" mode="widthFix"></image>
			</view>
			<view class="label">
				我的佣金
			</view>
			<image src="/static/right.png" mode="widthFix" class="right_icon"></image>
		</view>
		<!-- <view class="cell">
			<view class="left_icon">
				<image src="/static/icon_user_info.png" mode="widthFix"></image>
			</view>
			<view class="label">
				完善个人信息
			</view>
			<image src="/static/right.png" mode="widthFix" class="right_icon"></image>
		</view> -->
		<view class="cell" @click="myDeliveryAddress">
			<view class="left_icon">
				<image src="/static/icon_address.png" mode="widthFix"></image>
			</view>
			<view class="label">
				管理收货地址
			</view>
			<image src="/static/right.png" mode="widthFix" class="right_icon"></image>
		</view>
		<view class="cell" @click="myCardRepair">
			<view class="left_icon">
				<image src="/static/icon_card_repair.png" mode="widthFix"></image>
			</view>
			<view class="label">
				我要补时长
			</view>
			<image src="/static/right.png" mode="widthFix" class="right_icon"></image>
		</view>
		
		<view class="cell" @click="myCardGift">
			<view class="left_icon">
				<image src="/static/icon_card_gift.png" mode="widthFix"></image>
			</view>
			<view class="label">
				卡片赠送
			</view>
			<image src="/static/right.png" mode="widthFix" class="right_icon"></image>
		</view>
		<view class="cell" @click="myCardActive">
			<view class="left_icon">
				<image src="/static/icon_card_active.png" mode="widthFix"></image>
			</view>
			<view class="label">
				卡片激活
			</view>
			<image src="/static/right.png" mode="widthFix" class="right_icon"></image>
		</view>
		<view class="cell" v-if="userinfo.offline_role == '2'">
			<view class="left_icon">
				<image src="/static/icon_orders.png" mode="widthFix"></image>
			</view>
			<view class="label">
				店铺订单管理
			</view>
			<image src="/static/right.png" mode="widthFix" class="right_icon"></image>
		</view>
		<view class="cell"  v-if="userinfo.offline_role == '0'">
			<view class="left_icon">
				<image src="/static/icon_statistics.png" mode=""></image>
			</view>
			<view class="label">
				数据统计
			</view>
			<image src="/static/right.png" mode="widthFix" class="right_icon"></image>
		</view>
		
		<view class="logout">
			<button type="default" @click="logout" class="logout_btn">退出</button>
		</view>
		<m-tabbar fixed fill current="2" :tabbar="tabbar">
			<template v-slot:tabbar_index_1>
				<view class="custom_style" @tap="sancodeClick">
					<image src="../../static/sancode.png" style="width:78rpx;height: 78rpx;" mode="widthFix"></image>
				</view>
			</template>
		</m-tabbar>
		<scancodeCom ref="sancode" />
	</view>
</template>

<script>
	import TabbarConfig from '@/config/tabbar.js'
	import scancodeCom from '../shop/scancodeCom/scancodeCom.vue'
	export default {
		data() {
			return {
				statusBarHeight:'',
				userinfo:{},
				tabbar:TabbarConfig
			}
		},
		components:{scancodeCom},
		onLoad() {
		  this.GetStatusBarHeight();
		  this.userinfo = uni.getStorageSync('userinfo')
		  if(!this.userinfo || this.userinfo == '' || this.userinfo == '{}'){
			  uni.removeStorage('token')
			  //请先登录
			  uni.reLaunch({
			  	url:'/pages/login/login'
			  })
		  }
		},
		// 自定义此页面的转发给好友(已经有全局的分享方法，此处会覆盖全局)
		// onShareAppMessage(res) {
		// 	return {
		// 	  title: '页面分享的标题',
		// 	  path: '/pages/login/login',
		// 	  imageUrl: this.userinfo.avatar
		// 	}
		// },
		// // 自定义页面的分享到朋友圈
		// onShareTimeline(res) {
		// 	return {
		// 		title: '页面分享的标题',
		// 		path: '/pages/login/login',
		// 		imageUrl: this.userinfo.avatar
		// 	}
		// },
		methods: {
			//获取状态栏的高度
			GetStatusBarHeight() {
			    let that = this;
			       wx.getSystemInfo({
			        success: function (res) {
			            that.statusBarHeight = res.statusBarHeight;
			        },
			    });
			},
			toCooperationApply(){
				uni.navigateTo({url:'/pages/shop/cooperationApply/cooperationApply'})
			},
			toStoreData(){
				uni.navigateTo({url:'/pages/my/storeData/storeData'})
			},
			toMyShare(){
				uni.navigateTo({url:'/pages/my/myShare/myShare'})
			},
			// toShare(){
			// 	uni.navigateTo({url:'/pages/my/share/share'})
			// },
			myOrders(){
				console.log('toShop')
				uni.navigateTo({url:'/pages/my/myOrders'})
			},
			myDeliveryAddress(){
				uni.navigateTo({url:'/pages/my/myDeliveryAddress'})
			},
			myCommission(){
				uni.navigateTo({url:'/pages/my/myCommission/myCommission'})
			},
			myServices(){
				uni.navigateTo({url:'/pages/my/myServices/myServices'})
			},
			myVerification(){
				uni.navigateTo({url:'/pages/my/myVerification/myVerification'})
			},
			myCardRepair(){
				uni.showToast({title:'开发中',icon:'none'})
			},
			myCardGift(){
				uni.navigateTo({url:'/pages/my/cardGift/cardGift'})
			},
			myCardActive(){
				uni.navigateTo({url:'/pages/my/cardActive/cardActive'})
			},
			logout(){
				uni.removeStorageSync("token")
				uni.redirectTo({
					url:'/pages/login/login'
				})
			},
			sancodeClick(){
				this.$refs.sancode.sancode()
			}
			
		}
	}
</script>

<style scoped lang="scss">
	.container {
		background-image: url(../../static/my_bg.png);
		background-repeat: no-repeat;
		background-size: 100% auto;
		padding: 20rpx 24rpx;
		padding-bottom: calc(var(–window-bottom) + 20rpx);
		font-family: PingFangSC-Medium, PingFang SC;
		overflow: hidden;
		min-height: calc(100vh - 50px - env(safe-area-inset-bottom));
		padding-bottom: calc( 20rpx + constant(safe-area-inset-bottom)); /* 兼容 iOS < 11.2 */
		padding-bottom: calc( 20rpx + env(safe-area-inset-bottom)); /* 兼容 iOS >= 11.2 */
	}
	.user_info {
		width: 100%;
		height: 128rpx;
		margin-top: 50rpx;
		padding-left: 10rpx;
		display: flex;
		.avatar {
			width: 128rpx;
			height: 128rpx;
			border-radius: 50%;
			overflow: hidden;
			image {
				width: 128rpx;
				height: 100%;
			}
		}
		.other_info{
			display: flex;
			flex-direction: column;
			justify-content: center;
			margin-left: 14rpx;
			.name {
				font-size: 30rpx;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 42rpx;
				display: flex;
				align-items: center;
				.type {
					display: inline-block;
					height: 36rpx;
					padding: 0 14rpx;
					font-size: 24rpx;
					margin-left: 6rpx;
					border-radius: 18rpx;
					border: 2rpx solid #FFFFFF;
					line-height: 32rpx;
				}
			}
			.phone {
				font-size: 24rpx;
				font-weight: 400;
				color: #FFFFFF;
				line-height: 34rpx;
				margin-top: 4rpx;
			}
		}
	}

	.my_service {
		margin-top: 52rpx;
		width: 100%;
		height: 300rpx;
		background: #FFFFFF;
		box-shadow: 0px 4rpx 30rpx 0px rgba(0,0,0,0.05);
		border-radius: 12rpx;
		padding: 30rpx;
		.title {
			font-size: 30rpx;
			font-weight: 500;
			color: #222222;
			line-height: 30rpx;
		}
		
		.service_list {
			margin-top: 26rpx;
			display: flex;
			justify-content: space-between;
			.service_item {
				// width: 20%;
				flex: 1;
				height: 180rpx;
				border-radius: 8rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: space-around;
				padding-top: 10rpx;
				margin-right: 20rpx;
				.item_img {
					width: 60rpx;
					height: 60rpx;
					image {
						width: 100%;
						height: 100%;
					}
				}
				.item_name {
					font-size: 24rpx;
					color: #333333;
					line-height: 34rpx;
				}
			}
			.service_item_last {
				margin-right: 0;
			}
			.service_item_share {
				padding: 0;
				border: none;
			}
			.service_item_share::after {
				content: none;
				border: none;
			}
		}
		
	}

	.other_service {
		margin-top: 20rpx;
		width: 100%;
		.other_service_list {
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.other_service_item {
				// width: 220rpx;
				// width: 30%;
				flex: 1;
				margin-right: 20rpx;
				height: 116rpx;
				background: #FFFFFF;
				box-shadow: 0px 4rpx 30rpx 0px rgba(0,0,0,0.05);
				border-radius: 12rpx;
				display: flex;
				padding: 32rpx 24rpx;
				justify-content: space-between;
				align-items: center;
				.item_name {
					font-size: 24rpx;
					font-weight: 500;
					color: #333333;
					line-height: 34rpx;
				}
				.item_img {
					width: 52rpx;
					height: 52rpx;
					image {
						width: 100%;
						height: 100%;
					}
				}
			}
			.other_service_item:last-child{
				margin-right: 0;
			}
			.orders{
				background-image: url(../../static/bg_my_orders.png);
				background-position: right top;
				background-repeat: no-repeat;
				background-size: auto 100%;
			}
			.commission {
				background-image: url(../../static/bg_my_commission.png);
				background-position: right top;
				background-repeat: no-repeat;
				background-size: auto 100%;
			}
			.hxewm {
				background-image: url(../../static/bg_my_hxewm.png);
				background-position: right top;
				background-repeat: no-repeat;
				background-size: auto 100%;
			}
		}
	}

	.cell {
		height: 100rpx;
		background: #FFFFFF;
		box-shadow: 0px 4rpx 20rpx 0px rgba(102,102,102,0.05);
		border-radius: 12rpx;
		display: flex;
		align-items: center;
		position: relative;
		padding: 30rpx;
		margin-top: 20rpx;
		.left_icon {
			width: 32rpx;
			height: 32rpx;
			image {
				width: 100%;
				height: 100%;
			}
		}
		.label {
			margin-left: 20rpx;
			font-size: 28rpx;
			font-weight: 400;
			color: #222222;
		}
		.right_icon {
			position: absolute;
			right: 30rpx;
			top: 50%;
			transform: translateY(-50%);
			width: 16rpx;
			height: 16rpx;
		}
	}
	.logout {
		margin-top: 20rpx;
		.logout_btn {
			width: 100%;
			height: 88rpx;
			background: linear-gradient(90deg, #FF4050 0%, #FA2C1E 100%);
			border-radius: 44rpx;
			font-size: 32rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
		}
	}
	
</style>
